using System;
using System.Runtime.Serialization;
using Oracle.ManagedDataAccess.Client;

namespace Oracle.ManagedDataAccess.Types
{
	[Serializable]
	public class OracleTypeException : SystemException
	{
		protected string m_mesg;

		protected int m_number;

		protected const string dataProviderName = "Oracle Data Provider for .NET, Managed Driver";

		public override string Message
		{
			get
			{
				if (m_mesg != null)
				{
					return m_mesg;
				}
				return base.Message;
			}
		}

		public int Number => m_number;

		public override string Source => "Oracle Data Provider for .NET, Managed Driver";

		static OracleTypeException()
		{
		}

		public OracleTypeException(string message)
			: base(message)
		{
			m_mesg = message;
		}

		protected OracleTypeException(SerializationInfo info, StreamingContext context)
			: base(info, context)
		{
		}

		internal OracleTypeException(int mesgNum, params object[] args)
			: base(GetTypeMsg(mesgNum, args))
		{
			m_number = mesgNum;
			m_mesg = Message;
		}

		internal OracleTypeException()
		{
		}

		public override string ToString()
		{
			return base.ToString();
		}

		internal static string GetTypeMsg(int errCode, params object[] args)
		{
			string empty = string.Empty;
			empty = OracleStringResourceManager.GetErrorMesg(errCode);
			if (args.Length != 0)
			{
				empty = string.Format(empty, args);
			}
			return empty;
		}
	}
}
